@echo off
setlocal enabledelayedexpansion

:: 检查build目录
if not exist build (
    mkdir build
    echo Created build directory.
)

:: 进入build目录
cd build

:: 配置CMake项目
echo Configuring CMake project...
cmake -G "MinGW Makefiles" ..
if errorlevel 1 (
    echo CMake configuration failed.
    exit /b 1
)

:: 构建项目
echo Building project...
cmake --build .
if errorlevel 1 (
    echo Build failed.
    exit /b 1
)

:: 运行测试（如果启用）
echo Running tests...
ctest --output-on-failure
if errorlevel 1 (
    echo Tests failed.
    exit /b 1
)

echo Build completed successfully.
cd .. 